package com.littleu.yojoincn.controller.tt;


import com.littleu.yojoincn.common.LocalUser;
import com.littleu.yojoincn.common.interceptors.ScopeLevel;
import com.littleu.yojoincn.dto.customer.CustomerDTO;
import com.littleu.yojoincn.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/tt/customer")
@Validated
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @PostMapping("")
    @ScopeLevel
    public Map<String, Long> updateCustomer(@RequestBody @Validated CustomerDTO dto){
        Long cid = LocalUser.getCustomer().getId();
        Map<String, Long> map = new HashMap<>();
        Long celebrityId = this.customerService.update(dto, cid);
        map.put("celebrity_id", celebrityId);
        return map;
    }
}
